import java.security.*;

final class Util {

  private static Util instance = new Util();

  public static Util getInstance() {
    return instance;
  }

  private Util() {}

  public String md5(String subject) {
    byte[] defaultBytes = subject.getBytes();
    try{
      MessageDigest algorithm = MessageDigest.getInstance("MD5");
      algorithm.reset();
      algorithm.update(defaultBytes);
      byte messageDigest[] = algorithm.digest();
      
      StringBuffer hexString = new StringBuffer();
      for (int i=0;i<messageDigest.length;i++) {
        hexString.append(Integer.toHexString(0xFF & messageDigest[i]));
      }
      return hexString.toString();
    } catch(NoSuchAlgorithmException nsae){}
    return null;
  }
}